Skip to content

Conversation

@0xtygra
Copy link

@0xtygra 0xtygra commented Sep 25, 2025

Motivation

For a personal project I needed to generate the calldata for (but not actually fulfill) a listed NFT. The SDK has an internal api.ts that supports this but from my brief searching it looks like it isn't exposed.

Solution

image

I ended up forking the repo and using it locally. In doing so, i found that the JSDoc for api.getOrder and api.getOrders had an options.limit that was in fact omitted in the typescript. Additionally, passing an orderBy: "eth_price" to api.getOrder throws an error, so I also removed that as a configurable option.

A couple of other things i noticed:

  • a .env.example would be great, as well as updating the contributing.md to call out the need for a .env to run the tests. In addition, unless it's already done so, exposing the calldata generation functions from api.ts on the exported OpenSeaSDK object would be great!

serializeOrdersQueryOptions({
limit: 1,
orderBy,
orderBy: "created_date",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

ran into this error when trying to pass "eth_price"

@ryanio
Copy link
Collaborator

ryanio commented Sep 30, 2025

here is what the docs say, maybe we should just update the typedoc to include this?

The order in which to sort the results. Default: created_date NOTE: If eth_price is used, asset_contract_address and token_id are required.
https://docs.opensea.io/reference/get_listings

@0xtygra
Copy link
Author

0xtygra commented Oct 9, 2025

@ryanio i can update the PR to do that! i think i understand better now what the endpoint is for, i realise that each token might have multiple listings (in my mind i was only thinking of the "active" ie cheapest listing and wanted an endpoint to get me the listings of a collection, sorted by eth price such that it gives the "sort by price" view on the collection page)

@ryanio
Copy link
Collaborator

ryanio commented Oct 9, 2025

yeah it's a bit confusing. we used to have multiple listing currencies in OS1 but now in OS2 every chain has one listing currency (usually native, except for polygon is WETH) and one offer currency (usually wrapped native, polygon is WETH). there are helper fns in opensea-js now to get listing currency or offer currency for a chain if that's helpful for you.

ryanio added a commit that referenced this pull request Oct 14, 2025
Updates documentation for getOrder and getOrders to clarify that when using
orderBy: "eth_price", the asset_contract_address and token_ids parameters
must also be provided, as noted in the API documentation.

Fixes the confusion raised in #1752 without removing the parameters.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
ryanio added a commit that referenced this pull request Oct 14, 2025
)

* Clarify JSDoc for orderBy eth_price requirement

Updates documentation for getOrder and getOrders to clarify that when using
orderBy: "eth_price", the asset_contract_address and token_ids parameters
must also be provided, as noted in the API documentation.

Fixes the confusion raised in #1752 without removing the parameters.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Add runtime validation for eth_price orderBy parameter

- Throw descriptive error when orderBy is "eth_price" but required params are missing
- Added validation to both getOrder and getOrders methods
- Error message clearly indicates both asset_contract_address and token_ids are required
- This provides early error detection before API call

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* test: remove chain exclusions from getCollections test

- Remove Abstract, ApeChain, Blast, and Zora exclusions
- Keep only Solana excluded (no NFT collections)
- Test now runs for all chains except Solana

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
@ryanio
Copy link
Collaborator

ryanio commented Oct 14, 2025

fixed in #1774, thanks!

@ryanio ryanio closed this Oct 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants